Skip to content

[Improvement-18072][Api] Add user permission validation logic to the connectionTest, getDatabases, getTables, and getTableColumns methods in DataSourceController#18073

Open
njnu-seafish wants to merge 5 commits intoapache:devfrom
njnu-seafish:Improvement-18072
Open

[Improvement-18072][Api] Add user permission validation logic to the connectionTest, getDatabases, getTables, and getTableColumns methods in DataSourceController#18073
njnu-seafish wants to merge 5 commits intoapache:devfrom
njnu-seafish:Improvement-18072

Conversation

@njnu-seafish
Copy link
Contributor

@njnu-seafish njnu-seafish commented Mar 17, 2026

Was this PR generated or assisted by AI?

NO

Purpose of the pull request

close #18072

Brief change log

Add user permission validation logic to the connectionTest, getDatabases, getTables, and getTableColumns methods in DataSourceController

Verify this pull request

This pull request is code cleanup without any test coverage.

(or)

This pull request is already covered by existing tests, such as (please describe tests).

(or)

This change added tests and can be verified as follows:

(or)

Pull Request Notice

Pull Request Notice

If your pull request contains incompatible change, you should also add it to docs/docs/en/guide/upgrade/incompatible.md

@SbloodyS SbloodyS added the improvement make more easy to user or prompt friendly label Mar 18, 2026
@SbloodyS SbloodyS added this to the 3.4.2 milestone Mar 18, 2026
Copy link
Member

@ruanwenjun ruanwenjun left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert the unrelated change, you should review your pr first.

@ApiException(VERIFY_DATASOURCE_NAME_FAILURE)
public Result<Boolean> verifyDataSourceName(@Parameter(hidden = true) @RequestAttribute(value = Constants.SESSION_USER) User loginUser,
@RequestParam(value = "name") String name) {
public Result<Boolean> verifyDataSourceName(@RequestParam(value = "name") String name) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't change this method.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't change this method.

ok

* @return a boolean indicating whether Kerberos is currently active
*/
@Operation(summary = "getKerberosStartupState", description = "GET_USER_INFO_NOTES")
@Operation(summary = "getKerberosStartupState", description = "GET_KERBEROS_STARTUP_STATE")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't change the unrelated code of this issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't change the unrelated code of this issue.

ok

@njnu-seafish
Copy link
Contributor Author

Please revert the unrelated change, you should review your pr first.

Okay, I will create a separate issue and PR to address the inconsistent class comments in these classes.

@njnu-seafish njnu-seafish changed the title [Improvement-18072][Api] Add user permission validation logic to the getDatabases, getTables, and getTableColumns methods in DataSourceController [Improvement-18072][Api] Add user permission validation logic to the connectionTest, getDatabases, getTables, and getTableColumns methods in DataSourceController Mar 19, 2026
@njnu-seafish njnu-seafish requested a review from ruanwenjun March 19, 2026 06:49
}

if (!canOperatorPermissions(loginUser, new Object[]{datasourceId}, AuthorizationType.DATASOURCE,
ApiFuncIdentificationConstant.DATASOURCE)) {

Check warning

Code scanning / CodeQL

Potential database resource leak Warning

This Statement is not always closed on method exit.
if (!canOperatorPermissions(loginUser, new Object[]{datasourceId}, AuthorizationType.DATASOURCE,
ApiFuncIdentificationConstant.DATASOURCE)) {
throw new ServiceException(Status.USER_NO_OPERATION_PERM);
}

Check warning

Code scanning / CodeQL

Potential database resource leak Warning

This Statement is not always closed on method exit.
@sonarqubecloud
Copy link

Quality Gate Failed Quality Gate failed

Failed conditions
20.6% Coverage on New Code (required ≥ 60%)
18.1% Duplication on New Code (required ≤ 10%)

See analysis details on SonarQube Cloud

@njnu-seafish
Copy link
Contributor Author

njnu-seafish commented Mar 19, 2026

@SbloodyS @ruanwenjun Could you please prioritize reviewing this user authentication issue first when you have a moment? Thank you very much.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backend improvement make more easy to user or prompt friendly test

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Improvement][Api] Add user permission validation logic to the getDatabases, getTables, and getTableColumns methods in DataSourceController

3 participants